<include file="layout/header" />
<script src="__JS__/jquery.js"></script>
<script src="__JS__/dialog/layer.js"></script>
<script src="__JS__/dialog.js"></script>
<link href="__CSS__/manage/user/bootstrapValidator.min.css" rel="stylesheet">
<link href="__CSS__/manage/user/bootstrap-datetimepicker.min.css" rel="stylesheet"/>

<div id="content">
    <section id="widget-grid" class="">
        <div class="row">
            <article class="col-sm-12 col-md-10 col-lg-8">
                <div class="jarviswidget jarviswidget-color-greenDark jarviswidget-sortable" id="wid-id-1" data-widget-editbutton="false" data-widget-custombutton="false" data-widget-attstyle="jarviswidget-color-greenDark" role="widget" style="">

                    <header role="heading">
                        <div class="jarviswidget-ctrls" role="menu">
                            <a href="#" class="button-icon jarviswidget-toggle-btn" rel="tooltip" title="" data-placement="bottom" data-original-title="Collapse">
                                <i class="fa fa-minus "></i>
                            </a>
                            <a href="javascript:void(0);" class="button-icon jarviswidget-fullscreen-btn" rel="tooltip" title="" data-placement="bottom" data-original-title="Fullscreen">
                                <i class="fa fa-resize-full "></i>
                            </a>
                            <a href="javascript:void(0);" class="button-icon jarviswidget-delete-btn" rel="tooltip" title="" data-placement="bottom" data-original-title="Delete">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
						<div class="widget-toolbar" role="menu">
                            <a data-toggle="dropdown" class="dropdown-toggle color-box selector" href="javascript:void(0);">

                            </a>
                            <ul class="dropdown-menu arrow-box-up-right color-select pull-right">
                                <li><span class="bg-color-green" data-widget-setstyle="jarviswidget-color-green" rel="tooltip" data-placement="left" data-original-title="Green Grass"></span></li>
                                <li><span class="bg-color-greenDark" data-widget-setstyle="jarviswidget-color-greenDark" rel="tooltip" data-placement="top" data-original-title="Dark Green"></span></li>
                                <li><span class="bg-color-greenLight" data-widget-setstyle="jarviswidget-color-greenLight" rel="tooltip" data-placement="top" data-original-title="Light Green"></span></li>
                                <li><span class="bg-color-purple" data-widget-setstyle="jarviswidget-color-purple" rel="tooltip" data-placement="top" data-original-title="Purple"></span></li>
                                <li><span class="bg-color-magenta" data-widget-setstyle="jarviswidget-color-magenta" rel="tooltip" data-placement="top" data-original-title="Magenta"></span></li>
                                <li><span class="bg-color-pink" data-widget-setstyle="jarviswidget-color-pink" rel="tooltip" data-placement="right" data-original-title="Pink"></span></li>
                                <li><span class="bg-color-pinkDark" data-widget-setstyle="jarviswidget-color-pinkDark" rel="tooltip" data-placement="left" data-original-title="Fade Pink"></span></li>
                                <li><span class="bg-color-blueLight" data-widget-setstyle="jarviswidget-color-blueLight" rel="tooltip" data-placement="top" data-original-title="Light Blue"></span></li>
                                <li><span class="bg-color-teal" data-widget-setstyle="jarviswidget-color-teal" rel="tooltip" data-placement="top" data-original-title="Teal"></span></li>
                                <li><span class="bg-color-blue" data-widget-setstyle="jarviswidget-color-blue" rel="tooltip" data-placement="top" data-original-title="Ocean Blue"></span></li>
                                <li><span class="bg-color-blueDark" data-widget-setstyle="jarviswidget-color-blueDark" rel="tooltip" data-placement="top" data-original-title="Night Sky"></span></li>
                                <li><span class="bg-color-darken" data-widget-setstyle="jarviswidget-color-darken" rel="tooltip" data-placement="right" data-original-title="Night"></span></li>
                                <li><span class="bg-color-yellow" data-widget-setstyle="jarviswidget-color-yellow" rel="tooltip" data-placement="left" data-original-title="Day Light"></span></li>
                                <li><span class="bg-color-orange" data-widget-setstyle="jarviswidget-color-orange" rel="tooltip" data-placement="bottom" data-original-title="Orange"></span></li>
                                <li><span class="bg-color-orangeDark" data-widget-setstyle="jarviswidget-color-orangeDark" rel="tooltip" data-placement="bottom" data-original-title="Dark Orange"></span></li>
                                <li><span class="bg-color-red" data-widget-setstyle="jarviswidget-color-red" rel="tooltip" data-placement="bottom" data-original-title="Red Rose"></span></li>
                                <li><span class="bg-color-redLight" data-widget-setstyle="jarviswidget-color-redLight" rel="tooltip" data-placement="bottom" data-original-title="Light Red"></span>								</li>
                                <li><span class="bg-color-white" data-widget-setstyle="jarviswidget-color-white" rel="tooltip" data-placement="right" data-original-title="Purity"></span></li>
                                <li><a href="javascript:void(0);" class="jarviswidget-remove-colors" data-widget-setstyle="" rel="tooltip" data-placement="bottom" data-original-title="Reset widget color to default">Remove</a></li>
                            </ul>
                        </div>
                        <span class="widget-icon"> <i class="fa fa-edit"></i> </span>
                        <h2>修改用户</h2>

                        <span class="jarviswidget-loader"><i class="fa fa-refresh fa-spin"></i></span></header>

	                    <!-- widget div-->
	                    <div role="content">

	                        <!-- widget edit box -->
	                        <div class="jarviswidget-editbox">
	                            <!-- This area used as dropdown edit box -->

	                        </div>
	                        <!-- end widget edit box -->
	                        <section class="widget-body">

	                            <form class="smart-form form-horizontal" id="checkout-form" novalidate="novalidate">

	                                    <section class="all_list">
		                                    	<div class="row form-group">
			                                        <label class="col col-2 control-label" for="user_choose">请选择身份:</label>
			                                        <section class="col col-4">
			                                        	<label class="select">
				                                            <select class="form-control " name="type" id="user_choose" disabled>
				                                                <option value="1"  <if condition="$data.type eq 1">selected</if> >管理員</option>
				                                                <option value="2"  <if condition="$data.type eq 2">selected</if> >工作人员</option>
				                                                <option value="3"  <if condition="$data.type eq 3">selected</if> >在校学生</option>
				                                                <option value="4"  <if condition="$data.type eq 4">selected</if> >毕业学生</option>
				                                                <option value="5"  <if condition="$data.type eq 5">selected</if> >投资人</option>
				                                                <option value="6"  <if condition="$data.type eq 6">selected</if> >导师专家</option>
				                                                <option value="7"  <if condition="$data.type eq 7">selected</if> >学院用户</option>
				                                                <option value="8"  <if condition="$data.type eq 8">selected</if> >部门单位</option>
				                                            </select>
			                                        	</label>
			                                        </section>
			                                    </div>
		                                        <div class="row form-group">
		                                            <label for="user_name" class="user_label col col-2 control-label">姓名:</label>
		                                            <section class="col col-9">
		                                            	<label class="input">
		                                            		<input class="form-control input_absolute" name="name"  value="{{$data.name?$data.name:''}}" type="text">
		                                            	</label>

		                                            </section>
		                                        </div>
		                                        <div class="row form-group">
		                                            <label class=" col col-2 control-label">性别:</label>
		                                            <section class="col col-9">
		                                            	<div class="inline-group">
			                                            	<label class="radio">
		                                                        <input type="radio" class="radiobox style-0" value="1"  <if condition="$data.sex eq 1">checked</if> name="sex">
		                                                        <span>男</span>
			                                                </label>
			                                                <label class="radio">
		                                                        <input type="radio" class="radiobox style-0" value="2" <if condition="$data.sex eq 2">checked</if> name="sex">
		                                                        <span>女</span>
			                                                </label>
		                                            	</div>

		                                            </section>
		                                        </div>
		                                        <div class="form-group">
		                                            <label class="col col-2 control-label">手机:</label>
		                                            <section class="col col-9">
			                                            <label class="input">
			                                                <input name="phone" class="form-control"  value="{{$data.phone?$data.phone:''}}" type="text">
			                                            </label>
		                                            </section>
		                                        </div>
		                                        <div class="form-group">
		                                            <label class="col col-2 control-label">邮箱:</label>
		                                            <section class="col col-9">
		                                            	<div class="input">
		                                                	<input class="form-control"  value="{{$data.email?$data.email:''}}" name="email" type="text">
		                                            	</div>
		                                            </section>
		                                        </div>
		                                        <div class="form-group t7 t8">
	                                                <label class=" col col-2 control-label">身份证号:</label>
	                                                <section class="col col-9">
	                                                	<div class="input">
	                                                		<input class="form-control" value="{{$data.code?$data.code:''}}" name="code"  type="text">
	                                                	</div>
	                                                </section>
	                                            </div>
												<div class="row  form-group">
								            	 	<label for="user_native_place" class="user_label  col col-2 control-label">所在地:</label>
								            	 	<section class="col col-3">
														<label class="select">
										                	<select class="input-xs p_list" name="pid">
										                		<volist name="$areas['plist']" id="_p">
										                			<option <if condition="$_p['id'] eq $data['pid']">selected </if> value="{{$_p.id}}">{{$_p.name}}</option>
										                		</volist>
										                	</select>
										                	<i></i>
										                </label>
													</section>
													<section class="col col-3">
														<label class="select">
										                	<select class="input-xs c_list" name="cid">
										                		<volist name="$areas['clist']" id="_p">
										                			<option <if condition="$_p['id'] eq $data['cid']"> selected</if> value="{{$_p.id}}">{{$_p.name}}</option>
										                		</volist>
										                	</select>
										                	<i></i>
										                </label>
													</section>
													<section class="col col-3">
														<label class="select">
															<select class="input-xs a_list" name="aid">
										                		<volist name="$areas['alist']" id="_p">
										                			<option <if condition="$_p['id'] eq $data['aid']"> selected</if> value="{{$_p.id}}">{{$_p.name}}</option>
										                		</volist>
										                	</select>
										                	<i></i>
										                </label>
													</section>
												</div>
												<div class=" form-group">
													<label for="user_phone" class="user_label  col col-2 control-label">照片:</label>
													<section class="col col-9">
													<div class="col-md-10">
				                                    	<input type="file" name="photo" class="btn btn-default">
				                            		</div>
				                                    <div class="col-md-offset-2 img_box"></div>
				                                    </section>
												</div>
	                                       	</fieldset>
		                                </div>
	                                <footer>
	                                    <input type="hidden" name="id" value="{{$data.id}}">
	                                    <input type="button" value="保&nbsp;&nbsp;&nbsp;存" style="float: right;margin-right: 20px;margin-bottom: 10px;" id="user_save" class="btn btn-primary">
	                                    <input type="button" value="返&nbsp;&nbsp;&nbsp;回" style="float: right;margin-right:10px;margin-bottom: 10px;" class="btn btn-primary btn-info " onclick="window.history.back();">
	                                </footer>
	                            </form>
	                        </div>

	                    </div>
                    <!-- end widget content -->

                </div>
                <!-- end widget div -->
            </article>
        </div>
    </section>
</div>
<script src="__JS__/bootstrapValidator.min.js"></script>
<script src="__JS__/manage/user/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript">
    $('#user_save').click(function () {

        var bootstrapValidator = $('#checkout-form').data('bootstrapValidator');
        bootstrapValidator.validate();
        if(bootstrapValidator.isValid()){
            var url = "{{:url('user/edit')}}";
            var jumpUrl="{{$success_url}}";
            var data = $("#checkout-form").serializeArray();
            postData = {};
            $(data).each(function(i){
                postData[this.name] = this.value;
            });
            console.log(postData);
            $.post(url,postData,function(result){
                if(result.status == 0) {
                    return dialog.error(result.message);
                }
                if(result.status == 1) {
                    return dialog.success(result.message, jumpUrl);
                }
            },'JSON');
		}
    });

    $(function(){  
	   //省市区查询
	   function ajaxP(pid=0,typs=''){
	   		$.post('{{:url("manage/User/areas")}}',{"pid":pid},function(obj){
	   			var datas = $.parseJSON(obj);
	   			areaHtmls(datas,typs);
            });
	   }
	   $('.p_list').change(function(){
	   		var pid = $(this).val();
	   		ajaxP(pid,0);
	   })
   	   $('.c_list').change(function(){
	   		var pid = $(this).val();
	   		ajaxP(pid,1);
	   })
  	   //拼装
	   function areaHtmls(datas,ptype){
	   		var htmls = '';
			for(var i=0;i<datas.data.length;i++){
				htmls += '<option value="'+datas.data[i].id+'">'+datas.data[i].name+'</option>';
			}
	   		switch(ptype){
	   			case 0:
	   				var thiss_ = $('.c_list');
	   				$('.a_list').html('');
	   				break;
	   			case 1:
	   				var thiss_ = $('.a_list');
	   				break;
	   			default:
	   				var thiss_ = $('.p_list');
	   				break;
	   		}
			thiss_.html(htmls);
	   }
	});
</script>
<script src="__JS__/manage/user/user.js"></script>
<script src="__JS__/manage/user/add.js"></script>
<include file="layout/footer" />
		






